<extend name="Public/base"/>

<block name="nav">

    <ul class="nav nav-tabs" >




        <li
        <if condition="ACTION_NAME eq 'room'"> class="active"</if>
        ><a href='{:U("room",array("room_id"=>I("get.room_id"),"ajax"=>I("get.ajax")))}'>房间详情</a></li>
        <if condition="check_url(MODULE_NAME . '/' . CONTROLLER_NAME . '/log',UID)">
        <li
        <if condition="ACTION_NAME eq 'log'"> class="active"</if>
        ><a href='{:U("log",array("room_id"=>I("get.room_id"),"ajax"=>I("get.ajax")))}'>入住记录</a></li>

       </if>


        <li class="pull-right nav-tabls-plus">


            <span class="mr10">  {:F("Var_building")[$room["building"]][name]}</span>
            <span class="mr10">  {$room.floor}楼</span>
            <span class="mr10">  {$room.name}</span>
            <span class="mr10"> {:F("Var_room_type")[$room["type"]][name]}</span>
            <span class="mr10"> 可住{$room.maxnum}人</span>
        </li>



    </ul>
    <div>

    </div>

</block>



<block name="body">






        <div class="table_list">
            <table class="table table-striped table-bordered table-hover table-responsive" >


                <thead>

                <tr>
                    <th width="150">人员</th>
                    <th width="100">电话</th>
                    <th>劳动合同</th>
                    <th >身份证号</th>
                    <th>单位</th>
                    <th>接待单位</th>
                    <th width="100">入住时间</th>
                    <th width="120">退房时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <volist name="list" id="vo">
                    <tr>
                        <td>
                            <switch name="vo.type" >
                                <case value="2"><span class="badge badge-danger">临时</span></case>
                                <case value="1"><span class="badge badge-success">长期</span></case>


                            </switch>

                            <switch name="vo.sex" >
                                <case value="男"><span class="badge badge-info">{$vo.sex}</span></case>
                                <case value="女"><span class="badge badge-warning">{$vo.sex}</span></case>


                            </switch>



                            {$vo.name}
                        </td>

                        <td>{$vo.tel}</td>
                        <td>{$vo.ldht}</td>
                        <td>{$vo.sfz}</td>
                        <td>{$vo.danwei}</td>
                        <td>{$vo.jiedaidanwei}</td>

                        <td>{$vo.checkin}</td>
                        <td>{$vo.checkout}</td>

                        <td>

                            <if condition="check_url(MODULE_NAME . '/' . CONTROLLER_NAME . '/tiaofang',UID)">
                            <a  class="btn btn-xs btn-success tooltip-success" title="调房"  data-trigger="modal" data-title="房间调整" href="{:U('tiaofang',array('id'=>$vo['id']))}" ><i class="icon-edit"></i></a>

                                </if>
                            <a data-toggle="tooltip" title="退房" class="btn btn-xs btn-info tooltip-info ajax-get confirm" data-title="确定退房吗?" href="{:U('checkout',array('id'=>$vo['id']))}" data-original-title="修改"><i class="icon-sign-out "></i></a>

                        </td>


                    </tr>

                </volist>
                </tbody>

            </table>
        </div>




    <if condition="check_url(MODULE_NAME . '/' . CONTROLLER_NAME . '/checkin',UID)">

    <if condition="$room['maxnum'] gt $count">

        <div class="tabbable">
            <ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab4">
                <li class="active">
                    <a data-toggle="tab" href="#changqi">长期入住</a>
                </li>

                <li class="">
                    <a data-toggle="tab" href="#linshi">临时入住</a>
                </li>


            </ul>

            <div class="tab-content">
                <div id="changqi" class="tab-pane active">

                    <form method="post"  class="form-horizontal J_ajaxForm" action="{:U('checkin')}">
                        <div class="tab-content">




                            <input type="hidden"  name="room_id" value="{:I('get.room_id')}"   />



                            <div class="space-4"></div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label "> <span class="red">*</span>人员 </label>
                                <div class="col-sm-4">
                                    <input type="text"   id="changqi_name"  name="name"  class=" input-large"/>


                                    <select name="sex">
                                        <option value="男">男</option>
                                        <option value="女">女</option>
                                    </select>



                                </div>

                                <label class="col-sm-2 control-label "> <span class="red">*</span>手机号 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="tel"  class=" input-medium" maxlength="11" />

                                </div>
                            </div>



                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label "> <span class="red">*</span> 劳动合同号 </label>
                                <div class="col-sm-4">
                                    <input type="text" id="changqi_ldht"  name="ldht"  class="width-80" maxlength="11" />

                                </div>


                                <label class="col-sm-2 control-label "> <span class="red">*</span>单位 </label>
                                <div class="col-sm-4">
                                    <select class="input-large   selectpicker" id="danwei"   name="danwei">


                                        <option value="">请选择单位</option>


                                        <volist name=":F('Var_danwei_tree')" id="vo"  >
                                            <optgroup label="{$vo.name}">

                                                <volist name="vo[child]" id="v"  >

                                                    <option value="{$vo.name}-{$v.name}">{$v.name}</option>


                                                </volist>
                                            </optgroup>




                                        </volist>
                                        <option value="外部单位">外部单位</option>
                                    </select>

                                </div>
                            </div>

                            <div class="space-4"></div>





                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label "> 备注 </label>
                                <div class="col-sm-10">
                                    <textarea name="desc" class="width-90" rows="2" cols="57">{$data.remark}</textarea>
                                </div>
                            </div>



                            <div class="form-group">
                                <label class="col-sm-2 control-label "> <span class="red">*</span>入住时间 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="checkin" value="{:date('Y-m-d',time())}"  class=" J_date "/>
                                </div>

                                <label class="col-sm-2 control-label ">  <span class="red">*</span>身份证号 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="sfz"  class=" width-80"  />

                                </div>

                            </div>



                        </div>


                        <input type="hidden" name="type" value="1">
                        <input type="hidden" name="uid" >
                        <div class="form-actions">
                            <button class="btn btn-info ajax-post"   target-form="J_ajaxForm" type="submit"> 提交</button>

                            <a class="btn btn-return" onclick="history.go(-1)">返 回</a>
                        </div>




                    </form>
                </div>

                <div id="linshi" class="tab-pane">
                    <form method="post" class="form-horizontal J_ajaxForm_2" action="{:U('checkin')}">
                        <div class="tab-content">




                            <input type="hidden"  name="room_id" value="{:I('get.room_id')}"   />



                            <div class="space-4"></div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label "> <span class="red">*</span>人员 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="name"  class=" input-sm" />


                                    <select name="sex" >
                                        <option value="男">男</option>
                                        <option value="女">女</option>
                                    </select>



                                </div>

                                <label class="col-sm-2 control-label "> <span class="red">*</span>手机号 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="tel"  class=" input-medium" maxlength="11" />

                                </div>
                            </div>



                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label ">  <span class="red">*</span>身份证号 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="sfz"  class=" width-80"  />

                                </div>


                                <label class="col-sm-2 control-label ">接待单位 </label>
                                <div class="col-sm-4">
                                    <select class="input-large   selectpicker"  style="width: 500px" name="jiedaidanwei">


                                        <option value="">请选择单位</option>


                                        <volist name=":F('Var_danwei_tree')" id="vo"  >
                                            <optgroup label="{$vo.name}">

                                                <volist name="vo[child]" id="v"  >

                                                    <option value="{$vo.name}-{$v.name}">{$v.name}</option>


                                                </volist>
                                            </optgroup>



                                        </volist>
                                        <option value="外部单位">外部单位</option>
                                    </select>

                                </div>
                            </div>

                            <div class="space-4"></div>




                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label "> 备注 </label>
                                <div class="col-sm-10">
                                    <textarea name="desc" rows="2" cols="57" class=" width-80">{$data.remark}</textarea>
                                </div>
                            </div>



                            <div class="form-group">
                                <label class="col-sm-2 control-label "> <span class="red">*</span>入住时间 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="checkin" value="{:date('Y-m-d',time())}"  class=" J_date "/>
                                </div>

                                <label class="col-sm-2 control-label "> <span class="red">*</span>离开时间 </label>
                                <div class="col-sm-4">
                                    <input type="text"  name="checkout"  class=" J_datetime " value=""/>
                                </div>
                            </div>



                        </div>
                        <input type="hidden" name="type" value="2">
                        <input type="hidden" name="uid" >
                        <div class="form-actions">
                            <button class="btn btn-info ajax-post"   target-form="J_ajaxForm_2" type="submit"> 提交</button>

                            <a class="btn btn-return" onclick="history.go(-1)">返 回</a>
                        </div>




                    </form>
                </div>


            </div>
        </div>




    </if>

        </if>



</block>


<block name="script">

    <link rel="stylesheet" href="__CSS__/jquery-ui-1.10.3.full.min.css" />
    <script src="__JS__/jquery-ui-1.10.3.full.min.js"></script>




    <script>
        $("input[name='name']").autocomplete({
            delay: 500,
//            source: "availableTags",
            source: function(request, response) {
                $.ajax({
                    url: '/Admin/Public/get_users/key/' +  encodeURIComponent(request.term),
                    dataType: 'json',
                    success: function(json) {

                        if(json!=null){
                            response($.map(json, function(item) {
                                return {
                                    label: item.name,
                                    value: item.hthao
                                }
                            }));
                        }

                    }
                });
            },
            select: function(event, ui) {

                $("#changqi_ldht").val(ui.item.value);

                setvalue("changqi",ui.item.value);
                return false;
            },
            focus: function(event, ui) {
                return false;
            }
        });

//        $( "#changqi_name" ).autocomplete({
//            source: "{:U('Public/get_uers',array(''))}",
//            minLength: 2,
//            select: function( event, ui ) {
//                log( ui.item ?
//                "Selected: " + ui.item.value + " aka " + ui.item.id :
//                "Nothing selected, input was " + this.value );
//            }
//        });




        function  setvalue(v,key){

            v=$("#"+v)

            $.ajax({
                url: '/Admin/Public/get_user/id/' +  key,
                dataType: 'json',
                success: function(data) {

                    $("input[name='name']").val(data.name);

                    $("input[name='ldht']").val(data.hthao);
                    $("input[name='tel']").val(data.phone);
                    $("input[name='sfz']").val(data.id);
                    $("select[name='sex']").val(data.sex);
//                    v.find("select[name='sex'][@value='"+data.sex+"']").find("option[text='pxx']").attr("selected",true);
//                    v.find(".selectpicker").selectpicker("hide");

                    $("#danwei").chosen("destroy");
                    $("#danwei").val(data.dept);
                    //select筛选器
                    $("#danwei").chosen({
                        search_contains: true,
                    });

                }
            });





        }


        </script>


</block>